/*
Copyright (C) 1997-2001 Id Software, Inc.

This program is free software; you can redistribute it and/or
modify it under the terms of the GNU General Public License
as published by the Free Software Foundation; either version 2
of the License, or (at your option) any later version.

This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  

See the GNU General Public License for more details.

You should have received a copy of the GNU General Public License
along with this program; if not, write to the Free Software
Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.
*/

// Created on 31.10.2003 by RST.
// $Id: monsterinfo_t.java,v 1.2 2004/08/20 21:29:58 salomo Exp $
using System;
using QuakeFile = Suake2.UI.util.QuakeFile;
namespace Suake2.UI.game
{
	
	public class monsterinfo_t
	{
		
		public mmove_t currentmove;
		public int aiflags;
		public int nextframe;
		public float scale;
		
		public EntThinkAdapter stand;
		public EntThinkAdapter idle;
		public EntThinkAdapter search;
		public EntThinkAdapter walk;
		public EntThinkAdapter run;
		
		public EntDodgeAdapter dodge;
		
		public EntThinkAdapter attack;
		public EntThinkAdapter melee;
		
		public EntInteractAdapter sight;
		
		public EntThinkAdapter checkattack;
		
		public float pausetime;
		public float attack_finished;
		
		public float[] saved_goal = new float[]{0, 0, 0};
		public float search_time;
		public float trail_time;
		public float[] last_sighting = new float[]{0, 0, 0};
		public int attack_state;
		public int lefty;
		public float idle_time;
		public int linkcount;
		
		public int power_armor_type;
		public int power_armor_power;
		
		/// <summary>Writes the monsterinfo to the file.</summary>
		public virtual void  write(QuakeFile f)
		{
			System.IO.BinaryWriter temp_BinaryWriter;
			temp_BinaryWriter = new System.IO.BinaryWriter(f);
			temp_BinaryWriter.Write((System.Boolean) (currentmove != null));
			if (currentmove != null)
				currentmove.write(f);
			System.IO.BinaryWriter temp_BinaryWriter2;
			temp_BinaryWriter2 = new System.IO.BinaryWriter(f);
			temp_BinaryWriter2.Write((System.Int32) aiflags);
			System.IO.BinaryWriter temp_BinaryWriter3;
			temp_BinaryWriter3 = new System.IO.BinaryWriter(f);
			temp_BinaryWriter3.Write((System.Int32) nextframe);
			System.IO.BinaryWriter temp_BinaryWriter4;
			temp_BinaryWriter4 = new System.IO.BinaryWriter(f);
			temp_BinaryWriter4.Write((System.Single) scale);
			f.writeAdapter(stand);
			f.writeAdapter(idle);
			f.writeAdapter(search);
			f.writeAdapter(walk);
			f.writeAdapter(run);
			
			f.writeAdapter(dodge);
			
			f.writeAdapter(attack);
			f.writeAdapter(melee);
			
			f.writeAdapter(sight);
			
			f.writeAdapter(checkattack);
			
			System.IO.BinaryWriter temp_BinaryWriter5;
			temp_BinaryWriter5 = new System.IO.BinaryWriter(f);
			temp_BinaryWriter5.Write((System.Single) pausetime);
			System.IO.BinaryWriter temp_BinaryWriter6;
			temp_BinaryWriter6 = new System.IO.BinaryWriter(f);
			temp_BinaryWriter6.Write((System.Single) attack_finished);
			
			f.writeVector(saved_goal);
			
			System.IO.BinaryWriter temp_BinaryWriter7;
			temp_BinaryWriter7 = new System.IO.BinaryWriter(f);
			temp_BinaryWriter7.Write((System.Single) search_time);
			System.IO.BinaryWriter temp_BinaryWriter8;
			temp_BinaryWriter8 = new System.IO.BinaryWriter(f);
			temp_BinaryWriter8.Write((System.Single) trail_time);
			
			f.writeVector(last_sighting);
			
			System.IO.BinaryWriter temp_BinaryWriter9;
			temp_BinaryWriter9 = new System.IO.BinaryWriter(f);
			temp_BinaryWriter9.Write((System.Int32) attack_state);
			System.IO.BinaryWriter temp_BinaryWriter10;
			temp_BinaryWriter10 = new System.IO.BinaryWriter(f);
			temp_BinaryWriter10.Write((System.Int32) lefty);
			
			System.IO.BinaryWriter temp_BinaryWriter11;
			temp_BinaryWriter11 = new System.IO.BinaryWriter(f);
			temp_BinaryWriter11.Write((System.Single) idle_time);
			System.IO.BinaryWriter temp_BinaryWriter12;
			temp_BinaryWriter12 = new System.IO.BinaryWriter(f);
			temp_BinaryWriter12.Write((System.Int32) linkcount);
			
			System.IO.BinaryWriter temp_BinaryWriter13;
			temp_BinaryWriter13 = new System.IO.BinaryWriter(f);
			temp_BinaryWriter13.Write((System.Int32) power_armor_power);
			System.IO.BinaryWriter temp_BinaryWriter14;
			temp_BinaryWriter14 = new System.IO.BinaryWriter(f);
			temp_BinaryWriter14.Write((System.Int32) power_armor_type);
		}
		
		/// <summary>Writes the monsterinfo to the file.</summary>
		public virtual void  read(QuakeFile f)
		{
			System.IO.BinaryReader temp_BinaryReader;
			temp_BinaryReader = new System.IO.BinaryReader(f);
			temp_BinaryReader.BaseStream.Position = f.Position;
			if (temp_BinaryReader.ReadBoolean())
			{
				currentmove = new mmove_t();
				currentmove.read(f);
			}
			else
				currentmove = null;
			System.IO.BinaryReader temp_BinaryReader2;
			temp_BinaryReader2 = new System.IO.BinaryReader(f);
			temp_BinaryReader2.BaseStream.Position = f.Position;
			aiflags = temp_BinaryReader2.ReadInt32();
			System.IO.BinaryReader temp_BinaryReader3;
			temp_BinaryReader3 = new System.IO.BinaryReader(f);
			temp_BinaryReader3.BaseStream.Position = f.Position;
			nextframe = temp_BinaryReader3.ReadInt32();
			System.IO.BinaryReader temp_BinaryReader4;
			temp_BinaryReader4 = new System.IO.BinaryReader(f);
			temp_BinaryReader4.BaseStream.Position = f.Position;
			scale = temp_BinaryReader4.ReadSingle();
			stand = (EntThinkAdapter) f.readAdapter();
			idle = (EntThinkAdapter) f.readAdapter();
			search = (EntThinkAdapter) f.readAdapter();
			walk = (EntThinkAdapter) f.readAdapter();
			run = (EntThinkAdapter) f.readAdapter();
			
			dodge = (EntDodgeAdapter) f.readAdapter();
			
			attack = (EntThinkAdapter) f.readAdapter();
			melee = (EntThinkAdapter) f.readAdapter();
			
			sight = (EntInteractAdapter) f.readAdapter();
			
			checkattack = (EntThinkAdapter) f.readAdapter();
			
			System.IO.BinaryReader temp_BinaryReader5;
			temp_BinaryReader5 = new System.IO.BinaryReader(f);
			temp_BinaryReader5.BaseStream.Position = f.Position;
			pausetime = temp_BinaryReader5.ReadSingle();
			System.IO.BinaryReader temp_BinaryReader6;
			temp_BinaryReader6 = new System.IO.BinaryReader(f);
			temp_BinaryReader6.BaseStream.Position = f.Position;
			attack_finished = temp_BinaryReader6.ReadSingle();
			
			saved_goal = f.readVector();
			
			System.IO.BinaryReader temp_BinaryReader7;
			temp_BinaryReader7 = new System.IO.BinaryReader(f);
			temp_BinaryReader7.BaseStream.Position = f.Position;
			search_time = temp_BinaryReader7.ReadSingle();
			System.IO.BinaryReader temp_BinaryReader8;
			temp_BinaryReader8 = new System.IO.BinaryReader(f);
			temp_BinaryReader8.BaseStream.Position = f.Position;
			trail_time = temp_BinaryReader8.ReadSingle();
			
			last_sighting = f.readVector();
			
			System.IO.BinaryReader temp_BinaryReader9;
			temp_BinaryReader9 = new System.IO.BinaryReader(f);
			temp_BinaryReader9.BaseStream.Position = f.Position;
			attack_state = temp_BinaryReader9.ReadInt32();
			System.IO.BinaryReader temp_BinaryReader10;
			temp_BinaryReader10 = new System.IO.BinaryReader(f);
			temp_BinaryReader10.BaseStream.Position = f.Position;
			lefty = temp_BinaryReader10.ReadInt32();
			
			System.IO.BinaryReader temp_BinaryReader11;
			temp_BinaryReader11 = new System.IO.BinaryReader(f);
			temp_BinaryReader11.BaseStream.Position = f.Position;
			idle_time = temp_BinaryReader11.ReadSingle();
			System.IO.BinaryReader temp_BinaryReader12;
			temp_BinaryReader12 = new System.IO.BinaryReader(f);
			temp_BinaryReader12.BaseStream.Position = f.Position;
			linkcount = temp_BinaryReader12.ReadInt32();
			
			System.IO.BinaryReader temp_BinaryReader13;
			temp_BinaryReader13 = new System.IO.BinaryReader(f);
			temp_BinaryReader13.BaseStream.Position = f.Position;
			power_armor_power = temp_BinaryReader13.ReadInt32();
			System.IO.BinaryReader temp_BinaryReader14;
			temp_BinaryReader14 = new System.IO.BinaryReader(f);
			temp_BinaryReader14.BaseStream.Position = f.Position;
			power_armor_type = temp_BinaryReader14.ReadInt32();
		}
	}
}